import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import axios from 'axios'
//导入树形表格
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本
import VueQuillEditor from 'vue-quill-editor'
//富文本样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme


//设置接口默认地址
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/"
//需要授权的 API ，必须在请求头中使用 `Authorization` 字段提供 `token` 令牌
axios.interceptors.request.use(config => {
    config.headers.Authorization = window.sessionStorage.getItem("token")
    //一定要return config
    return config
})
//将axios定义到$http中
Vue.prototype.$http = axios

//挂载vue-table-tree
Vue.component('tree-table', TreeTable)

//挂载富文本
Vue.use(VueQuillEditor, /* { default global options } */)

//全局过滤器
Vue.filter("dataFormate",function(originVaule){
    let dt = new Date(originVaule)
    let y = (dt.getFullYear() + '').padStart(2,'0')
    let m = (dt.getMonth() + 1 + '').padStart(2,'0')
    let d = (dt.getDate() + '').padStart(2,'0')
    let h = (dt.getHours() + '').padStart(2,'0')
    let mm =( dt.getMinutes() + '').padStart(2,'0')
    let ss =( dt.getSeconds() + '').padStart(2,'0')
    return `${y}-${m}-${d} ${h}:${mm}:${ss}`
})


Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
